home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / latex209 / contrib / rail / lex.l < prev    next >
Text File  |  1993-01-11  |  1KB  |  97 lines

  1. /* lex.l - lexical analyzer for rail program */
  2.  
  3. %{
  4.  
  5. #include "rail.h"
  6. #include "gram.h"
  7.  
  8. int line;    /* current input line */
  9. int copy;    /* copy to output flag */
  10.  
  11. #define    COPY    (copy && fputs(yytext,outf))
  12.  
  13. extern YYSTYPE yylval;
  14.  
  15. %}
  16.  
  17. %%
  18.  
  19. [a-zA-Z_][0-9a-zA-Z_.]* {
  20.         COPY;
  21.         yylval.id=lookup(yytext);
  22.         return(IDENTIFIER);
  23. }
  24.  
  25. [0-9][0-9]* {
  26.         COPY;
  27.         yylval.num=atoi(yytext);
  28.         return(NUMBER);
  29. }
  30.  
  31. \\rail@i {
  32.         COPY;
  33.         return(RAILI);
  34. }
  35.  
  36. \\rail@p {
  37.         COPY;
  38.         return(RAILP);
  39. }
  40.  
  41. \\rail@t {
  42.         COPY;
  43.         return(RAILT);
  44. }
  45.  
  46. \\par        COPY;
  47.  
  48. \\\\ {        COPY;
  49.         return(RAILCR);
  50. }
  51.  
  52. \\[a-zA-Z@]+ {
  53.         COPY;
  54.         return(CS);
  55. }
  56.  
  57. \\[^ \n\t] {
  58.         COPY;
  59.         return(CS);
  60. }
  61.  
  62. '[^\n\t']*' {
  63.         COPY;
  64.         yytext[yyleng-1]='\0';
  65.         yylval.text=mcheck(strdup(yytext+1));
  66.         return(STRING);
  67. }
  68.  
  69. \[[^\n\t\]]*\] {
  70.         COPY;
  71.         yytext[yyleng-1]='\0';
  72.         yylval.text=mcheck(strdup(yytext+1));
  73.         return(ANNOT);
  74. }
  75.  
  76. \"[^\n\t\"]*\" {
  77.         COPY;
  78.         yytext[yyleng-1]='\0';
  79.         yylval.text=mcheck(strdup(yytext+1));
  80.         return(STRING);
  81. }
  82.  
  83. [ \t]+ {
  84.         COPY;
  85. }
  86.  
  87. \n {
  88.         COPY;
  89.         line++;
  90. }
  91.  
  92. . {
  93.         COPY;
  94.         return(yytext[0]);
  95. }
  96.  
  97.